﻿using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFDemoMVVM.ViewModel
{
    public class ValueConverterViewModelValidator : AbstractValidator<ValueConverterViewModel>
    {
        public ValueConverterViewModelValidator()
        {
            RuleFor(x => x.UserName)
                .NotEmpty().WithMessage("用户名必须不为空")
                .Length(6, 10).WithMessage("用户名长度必须在6和10之间");

            RuleFor(x => x.Age)
                .InclusiveBetween(18, 110).WithMessage("年龄必须在18和110之间");

            RuleFor(x => x.Password)
                .NotEmpty().WithMessage("密码必须不为空")
                .Length(8, 20).WithMessage("密码长度必须在8和20之间");
        }
    }
}
